import Area from './Area.js'
import Sprite from './Sprite.js'

export default class AirPlane extends Sprite {
  // 移动速度
  moveSpeed: number = 0
  attackSpeed: number = 0
  attack: number = 0
  armor: number = 0
  direction: number = 0
  minX: number = 0
  maxX: number = 0
  minY: number = 0
  maxY: number = 0
  constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0, imgPath: string = '') {
    super(x, y, width, height, imgPath)
  }
  setMoveArea(sx: number, sy: number) {
    this.minX = (this.width / 2) * -1
    this.minY = (this.height / 2) * -1
    this.maxX = sx - this.width / 2
    this.maxY = sy - this.height / 2
    // console.log(sx, sy, this)
  }
  move() {
    this.x += this.moveSpeed * Math.cos(this.direction)
    this.y += this.moveSpeed * Math.sign(this.direction)
    this.x = this.x <= this.minX ? this.minX : this.x
    this.y = this.y <= this.minY ? this.minY : this.y
    this.x = this.x >= this.maxX ? this.maxX : this.x
    this.y = this.y >= this.maxY ? this.maxY : this.y
  }
  
}
